use actix_web::{App, get, HttpServer, Responder, web};
// http://localhost:3000/hello/world1
#[get("/hello/{name}")]
async fn greet(name: web::Path<String>) -> impl Responder {
    format!("Hello {name}!")
    // return format!("Hello {name}!")
}

// http://localhost:3000/hello
#[get("/hello")]
async fn hello() -> impl Responder {
    "Hello1"
}
// http://localhost:3000/

#[get("/")]
async fn index() -> impl Responder {
    "Hello world!"
}

#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new().service(greet);
        App::new().service(hello);
        App::new().service(index)
    })
        .bind(("127.0.0.1", 3000))?
        .run()
        .await
}